"use strict";
cc._RF.push(module, '478a4G5TOxDIb0R6q6c8QU+', 'TouchViewUI');
// scripts/TouchViewUI.js

"use strict";

var e = require;
var t = module;
var o = exports;

var _ii,
    nn = void 0 && (void 0).__extends || (_ii = function ii(t, e) {
  return (_ii = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _ii(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    rr = void 0 && (void 0).__awaiter || function (t, e, o, i) {
  return new (o || (o = Promise))(function (n, a) {
    function r(t) {
      try {
        l(i.next(t));
      } catch (e) {
        a(e);
      }
    }

    function s(t) {
      try {
        l(i["throw"](t));
      } catch (e) {
        a(e);
      }
    }

    function l(t) {
      var e;
      t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
        t(e);
      })).then(r, s);
    }

    l((i = i.apply(t, e || [])).next());
  });
};

var oo = void 0 && (void 0).__decorate || function (e, t, a, n) {
  var i,
      o = arguments.length,
      s = o < 3 ? t : null === n ? n = Object.getOwnPropertyDescriptor(t, a) : n;
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, a, n);else for (var r = e.length - 1; r >= 0; r--) {
    (i = e[r]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, a, s) : i(t, a)) || s);
  }
  return o > 3 && s && Object.defineProperty(t, a, s), s;
};

Object.defineProperty(o, "__esModule", {
  value: !0
});

var a = e("BaseModuleUI"),
    n = e("NotifyEventType"),
    i = e("GlobalParams"),
    r = e("AssetsManager"),
    s = e("CommonHelper"),
    l = e("PureHelper"),
    _ = e("sdkConfig"),
    c = e("AD"),
    d = e("GamePlayerInfo"),
    h = cc._decorator,
    u = h.ccclass,
    p = h.property,
    m = function (e) {
  function t() {
    var t = null !== e && e.apply(this, arguments) || this;
    return t.touch_node = null, t.touch_bg = null, t.touch_bar = null, t.use_skill_list = [], t.attack_node = null, t.skill_one_node = null, t.skill_two_node = null, t.skill_three_node = null, t.game_time_label = null, t.native_icon_node = null, t.game_player_info = null, t.key_space = !1, t;
  }

  return nn(t, e), t.prototype.initView = function () {
    e.prototype.initView.call(this), this.native_icon_node.active = _["default"].platform != _.EPlatform.NO_AD && !c["default"].getInstance().getGameTestVersion() && !i.GlobalParams.PlayGuideMode, this.touch_node.active = _["default"].platform != _.EPlatform.NET_4399, this.game_player_info = this.node.getComponent(d["default"]), this.attack_node.addComponent(cc.Button), this.skill_one_node.addComponent(cc.Button), this.skill_two_node.addComponent(cc.Button), this.skill_three_node.addComponent(cc.Button), this.attack_node.getComponent(cc.Button).transition = cc.Button.Transition.SCALE, this.attack_node.getComponent(cc.Button).zoomScale = 0.9, this.skill_one_node.getComponent(cc.Button).transition = cc.Button.Transition.SCALE, this.skill_one_node.getComponent(cc.Button).zoomScale = 0.9, this.skill_two_node.getComponent(cc.Button).transition = cc.Button.Transition.SCALE, this.skill_two_node.getComponent(cc.Button).zoomScale = 0.9, this.skill_three_node.getComponent(cc.Button).transition = cc.Button.Transition.SCALE, this.skill_three_node.getComponent(cc.Button).zoomScale = 0.9, this.game_time_label.string = "00:00", this.showGiveTime();
  }, t.prototype.addEvent = function () {
    this.touch_node.on(cc.Node.EventType.TOUCH_START, this.TouchStart, this), this.touch_node.on(cc.Node.EventType.TOUCH_MOVE, this.TouchMove, this), this.touch_node.on(cc.Node.EventType.TOUCH_END, this.TouchEnd, this), this.touch_node.on(cc.Node.EventType.TOUCH_CANCEL, this.TouchEnd, this), this.attack_node.on("click", this.playerAttack, this), this.skill_one_node.on("click", this.playerSkillOne, this), this.skill_two_node.on("click", this.playerSkillTwo, this), this.skill_three_node.on("click", this.playerSkillThree, this), cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this), cc.systemEvent.on(cc.SystemEvent.EventType.KEY_UP, this.onKeyUp, this);
  }, t.prototype.showGiveTime = function () {
    var e = this;

    if (i.GlobalParams.GameStart) {
      var t = new Date().getTime() - i.GlobalParams.GamePlayTime;
      this.game_time_label.string = s["default"].getTimeStrByNum(t, !1, 2);
    }

    this.scheduleOnce(function () {
      e.showGiveTime();
    }, 1);
  }, t.prototype.playerAttack = function () {
    i.GlobalParams.GameStart && this.emitEvent(n["default"].SEND_PLAYER_FREE_SKILL);
  }, t.prototype.playerSkillOne = function () {
    i.GlobalParams.GameStart && (this.emitEvent(n["default"].SEND_PLAYER_FREE_SKILL_ONE), this.skill_one_node.getChildByName("cooling").active || (this.use_skill_list[0].node.active = !0, this.use_skill_list[0].setAnimation(0, "animation", !0)));
  }, t.prototype.playerSkillTwo = function () {
    i.GlobalParams.GameStart && (this.emitEvent(n["default"].SEND_PLAYER_FREE_SKILL_TWO), this.skill_two_node.getChildByName("cooling").active || (this.use_skill_list[1].node.active = !0, this.use_skill_list[1].setAnimation(0, "animation", !0)));
  }, t.prototype.playerSkillThree = function () {
    i.GlobalParams.GameStart && (this.emitEvent(n["default"].SEND_PLAYER_FREE_SKILL_THREE), this.skill_three_node.getChildByName("cooling").active || (this.use_skill_list[2].node.active = !0, this.use_skill_list[2].setAnimation(0, "animation", !0)));
  }, t.prototype.onKeyDown = function (e) {
    switch (e.keyCode) {
      case cc.macro.KEY.space:
        this.key_space = !0;
    }
  }, t.prototype.onKeyUp = function (e) {
    switch (e.keyCode) {
      case cc.macro.KEY.q:
        this.emitEvent(n["default"].SEND_PLAYER_FREE_SKILL);
        break;

      case cc.macro.KEY.w:
        this.key_space ? (this.emitEvent(n["default"].SEND_ADD_SKILL_LEVEL_INDEX, 0), this.key_space = !1) : this.emitEvent(n["default"].SEND_PLAYER_FREE_SKILL_ONE);
        break;

      case cc.macro.KEY.e:
        this.key_space ? (this.emitEvent(n["default"].SEND_ADD_SKILL_LEVEL_INDEX, 1), this.key_space = !1) : this.emitEvent(n["default"].SEND_PLAYER_FREE_SKILL_TWO);
        break;

      case cc.macro.KEY.r:
        this.key_space ? (this.emitEvent(n["default"].SEND_ADD_SKILL_LEVEL_INDEX, 2), this.key_space = !1) : this.emitEvent(n["default"].SEND_PLAYER_FREE_SKILL_THREE);
        break;

      case cc.macro.KEY.space:
        this.key_space = !1;
        break;

      case cc.macro.KEY.n:
        this.emitEvent(n["default"].SEND_ADD_SKILL_LEVEL_INDEX, 0);
        break;

      case cc.macro.KEY.m:
        this.emitEvent(n["default"].SEND_ADD_SKILL_LEVEL_INDEX, 1);
        break;

      case cc.macro.KEY.i:
        this.emitEvent(n["default"].SEND_USE_PLAYER_SKILL_INDEX, 1);
        break;

      case cc.macro.KEY.o:
        this.emitEvent(n["default"].SEND_USE_PLAYER_SKILL_INDEX, 2);
        break;

      case cc.macro.KEY.num1:
      case cc.macro.KEY.f1:
        this.game_player_info.showTopInfoNode(0);
        break;

      case cc.macro.KEY.num2:
      case cc.macro.KEY.f2:
        this.game_player_info.showTopInfoNode(1);
        break;

      case cc.macro.KEY.num3:
      case cc.macro.KEY.f3:
        this.game_player_info.showTopInfoNode(2);
        break;

      case cc.macro.KEY.num4:
      case cc.macro.KEY.f4:
        this.game_player_info.showTopInfoNode(3);
        break;

      case cc.macro.KEY.escape:
        cc.find("Canvas").getChildByName("SettingViewUI") ? cc.find("Canvas").getChildByName("SettingViewUI").destroy() : this.uiManager.showPopup("SettingViewUI");
        break;

      case cc.macro.KEY.tab:
        cc.find("Canvas").getChildByName("GameMenuViewUI") ? cc.find("Canvas").getChildByName("GameMenuViewUI").destroy() : cc.find("Canvas").addChild(cc.instantiate(r["default"].getInstance().getFightPrefab("GameMenuViewUI")));
        break;

      case cc.macro.KEY.t:
        cc.find("Canvas").getChildByName("GameEquipViewUI") ? cc.find("Canvas").getChildByName("GameEquipViewUI").destroy() : cc.find("Canvas").addChild(cc.instantiate(r["default"].getInstance().getFightPrefab("GameEquipViewUI")));
        break;

      case cc.macro.KEY.b:
        this.game_player_info.quickBuyEquip();
    }
  }, t.prototype.TouchStart = function (e) {
    var t = e.touch.getLocation();
    t = this.touch_node.convertToNodeSpaceAR(t), this.touch_bg.setPosition(t);
  }, t.prototype.TouchMove = function (e) {
    var t = e.touch.getLocation();
    t = this.touch_bg.convertToNodeSpaceAR(t), Math.abs(l["default"].Distance(t, cc.v2(0, 0))) > 50 && (t = l["default"].getTailPosOuter(t, cc.v2(0, 0), -50)), this.touch_bar.setPosition(t);
    var o = cc.v2(t.x, t.y).sub(cc.v2(0, 0)).normalize();
    this.emitEvent(n["default"].SEND_PLAYER_MOVE_INFO, o);
  }, t.prototype.TouchEnd = function () {
    this.touch_bar.setPosition(cc.v2(0, 0)), this.emitEvent(n["default"].SEND_PLAYER_STOP_MOVE_INFO), this.touch_bg.setPosition(cc.v2(-80, -20));
  }, oo([p(cc.Node)], t.prototype, "touch_node", void 0), oo([p(cc.Node)], t.prototype, "touch_bg", void 0), oo([p(cc.Node)], t.prototype, "touch_bar", void 0), oo([p(sp.Skeleton)], t.prototype, "use_skill_list", void 0), oo([p(cc.Node)], t.prototype, "attack_node", void 0), oo([p(cc.Node)], t.prototype, "skill_one_node", void 0), oo([p(cc.Node)], t.prototype, "skill_two_node", void 0), oo([p(cc.Node)], t.prototype, "skill_three_node", void 0), oo([p(cc.Label)], t.prototype, "game_time_label", void 0), oo([p(cc.Node)], t.prototype, "native_icon_node", void 0), oo([u], t);
}(a["default"]);

o["default"] = m;

cc._RF.pop();